%%
a=load ('/users/pmanis/desktop/lyoly.05jun07a.mat')
filename = '/users/pmanis/desktop/recover.mat';
fn = fieldnames(a);
for i = 1:length(fn)
    if (i == 1)
        mode = '';
    else
        mode = '-append';
    end;
    if(strcmp(fn{i},'db_1'))
        subs = 'db_5';
    else
        subs = fn{i};
    end;
    cmd=sprintf('%s = a.%s;',subs, fn{i})
    eval(cmd)
    if(strcmp(cmd, 'Index'))
    save(filename, subs, mode, '-v6');
    end;
end;
   Index = load(filename, 'Index');
   Index = Index.Index;
   s=length(Index)
   s = s + 1; % position to next entry
   t = now; % get serial date/time number
   Index(s).date = datestr(t,1);
   Index(s).time = datestr(t,13);
   Index(s).block = block_no;
   Index(s).record = max(RL);
   Index(s).type = 'DATA';
   Index(s).type2 = eval([sfb '.Name.v']);
   Index(s).MatName = block_id;
   
   fprintf(1, 'Updating index\n');
   save(filename, 'Index', '-append', FILEFORMAT);